from flask import Flask
from app.error import register_error_handlers
from app.blueprints import register_blueprints
from app.customer_logging import setup_logging


def create_app(config_class="config.Config"):
    app = Flask(__name__)
    app.config.from_object(config_class)
    setup_logging(
        app,
        enable_console=True,
        enable_file=True,
        file_path=app.config["LOG_FILE_PATH"],  # 从配置读取
        log_level="INFO",
    )
    register_blueprints(app)
    register_error_handlers(app)
    return app
